package recharge_management

import (
	"context"

	"gitee.com/liuxuezhan/ar-platform/admin-api/internal/svc"
	"gitee.com/liuxuezhan/ar-platform/admin-api/internal/types"
	"gitee.com/liuxuezhan/ar-platform/rpc-client/assetsClient/rpc"

	"github.com/zeromicro/go-zero/core/logx"
)

type UsdtCreateLogic struct {
	logx.Logger
	ctx    context.Context
	svcCtx *svc.ServiceContext
}

// usdt--新增
func NewUsdtCreateLogic(ctx context.Context, svcCtx *svc.ServiceContext) *UsdtCreateLogic {
	return &UsdtCreateLogic{
		Logger: logx.WithContext(ctx),
		ctx:    ctx,
		svcCtx: svcCtx,
	}
}

func (l *UsdtCreateLogic) UsdtCreate(req *types.UsdtCreateRequest) (resp *types.UsdtCreateResponse, err error) {
	in := rpc.UsdtCreateRequest{
		Name:     req.Name,
		UsdtType: req.UsdtType,
		QrCode:   req.QrCode,
		Address:  req.Address,
		Sort:     uint32(req.Sort),
	}
	createResponse, err := l.svcCtx.AssetsRpc.TenantChannel.UsdtCreate(l.ctx, &in)
	if err != nil {
		return &types.UsdtCreateResponse{
			CommonResp: types.CommonResp{
				Code:    createResponse.CommonResp.Code,
				Message: createResponse.CommonResp.Message,
			},
		}, err
	}

	return &types.UsdtCreateResponse{
		CommonResp: types.CommonResp{
			Code:    0,
			Message: "Success",
		},
	}, nil
}

// type ServiceContext struct {
//	Config           config.Config
//	LoginRpc         user.User
//	AssetsRPCService AssetsRPCService
// }
//
// type AssetsRPCService struct {
//	TenantchannelRPC tenantchannel.TenantChannel
// }
//
// func NewAssetsRPCService(client zrpc.Client) AssetsRPCService {
//	return AssetsRPCService{TenantchannelRPC: tenantchannel.NewTenantChannel(client)}
// }
//
// func NewServiceContext(c config.Config) *ServiceContext {
//	// 自定义拦截器
//	client := zrpc.MustNewClient(
//		zrpc.RpcClientConf{
//			Target: rpc.GenRpcTarget(c.AuthRoleRpc),
//		},
//		zrpc.WithUnaryClientInterceptor(
//			interceptors.ClientErrorInterceptor(c.Name, c.Name),
//		),
//	)
//	// 自定义拦截器
//	assetsClient := zrpc.MustNewClient(
//		zrpc.RpcClientConf{
//			Target: rpc.GenRpcTarget(c.AssetsRPC),
//		},
//		zrpc.WithUnaryClientInterceptor(
//			interceptors.ClientErrorInterceptor(c.Name, c.Name),
//		),
//	)
//	loginRPC := user.NewUser(client)
//
//	return &ServiceContext{
//		Config:           c,
//		LoginRpc:         loginRPC,
//		AssetsRPCService: NewAssetsRPCService(assetsClient),
//	}
// }
//
